<template>
  <div class="search-list">
    <transition-group tag="ul" name="list">
      <li class="search-item" v-for="item of searches" :key="item"
      @click.stop="searchItem(item)">
        <span class="text">{{item}}</span>
        <span class="icon">
          <i class="icon-delete" @click.stop="deleteOne(item)"></i>
        </span>
      </li>
    </transition-group>
  </div>
</template>
<script>
export default {
  name: 'SearchList',
  props: {
    searches: {
      type: Array,
      default: () => []
    }
  },
  methods: {
    deleteOne (item) {
      this.$emit('deleteOne', item)
    },
    searchItem (item) {
      this.$emit('searchItem', item)
    }
  }
}
</script>
<style lang="scss" scoped>
@import 'common/scss/variable.scss';
.search-list{
  .search-item{
    display: flex;
    align-items: center;
    height: 0.8rem;
    &.list-enter-active, &.list-leave-active{
      transition: all 0.1s;
    }
    &.list-enter, &.list-leave-to{
      height: 0;
    }
    .text{
      flex: 1;
      color: $color-text-l;
      font-size: 0.28rem;
    }
    .icon{
      .icon-delete{
        font-size: 0.20rem;
        color: $color-text-d;
        vertical-align: middle;
        position: relative;
        top: -0.1rem
      }
    }
  }
}
</style>
